package com.rockcent.mall.lib.repository;

import com.rockcent.common.common.PageResult;
import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.MerchantCoupon;
import com.rockcent.mall.lib.domain.Product;
import com.rockcent.mall.lib.domain.enumclass.CouponType;
import com.rockcent.mall.lib.domain.enumclass.MerchantCouponStatus;
import com.rockcent.mall.lib.dto.IntegrationCouponRespDto;
import com.rockcent.mall.lib.dto.MerchantCouponDto;

import java.math.BigDecimal;
import java.util.List;

/**
 * Created by zhangjh on 2016/10/11.
 */
public interface MerchantCouponRepositoryCustom {

    PageResult findByMerchantIdAndSharing(Long mallId,Long merchantId, String isSharing, String name, String couponType, String isOnLine, String orderFieldName, String isDesc, String status, PageResult pageResult);

    PageResult findByMerchantId(Long merchantId, String name, String couponType, String status, PageResult pageResult);

    Long countCouponVerified(Long merchantId, Long mallId, Long couponId, PageResult pageResult);

    Long countCouponSendCustomer(Long merchantId, Long mallId, Long couponId, PageResult page);

    /**
     * 根据商城查券
     */
    PageResult<MerchantCoupon> findByShowOnCenterAndStatusAndMallId(Whether ShowOnCenter, String type, MerchantCouponStatus status, Long mallId, PageResult pageResult);

    List<MerchantCoupon> findByMerchantIdAndCouponIds(Long merchantId, List<Long> couponIds);

    List<MerchantCoupon> getUseableCoupons(Product product);

    Long getCouponCount(Long mallId, Long merchantId);

    List<Long> findAllExpiredCouponIds();

    PageResult<MerchantCouponDto> findIntegrationCouponPage(Long mallId, String name, String merchantName, BigDecimal faceValue, String status, String integrationStatus, String type, PageResult pageResult);

    Long queryTotalNum(Long integrationChannelId);

    Long queryMaxBatchPutNo(Long mallId, Long integrationChannelId);

    BigDecimal queryAvailableAmountByMallId(Long mallId, Long channelId);

    List<IntegrationCouponRespDto> findByIntegrationAndIntegrationChannelIdAndStatus(Whether yes, Long integrationChannelId, MerchantCouponStatus status);

    IntegrationCouponRespDto findOneByIntegrationAndIntegrationChannelIdAndStatusAndFaceVal(Whether yes, Long integrationChannelId, MerchantCouponStatus issued, BigDecimal faceVal);
}
